import React from 'react';

import './App.scss';

// BrowserRouter as Router,
import { Route, Switch, Redirect } from 'react-router-dom';

// 导入页面组件

import { AuthRoute } from '@/components/AuthRoute';

// 注意：此处，导入的是 Router 组件！
import { Router } from 'react-router-dom';
import { customHistory } from '@/utils';

import { lazy, Suspense } from 'react';
const Login = lazy(() => import('./pages/Login'));
const Layout = lazy(() => import('./pages/Layout'));

export default function App() {
  return (
    <Router history={customHistory}>
      <Suspense fallback={<div className="loading">loading...</div>}>
        <div className="app">
          <Switch>
            <Route path="/login" component={Login} />
            {/* <Route path="/home" component={Layout} /> */}
            <AuthRoute path="/home" component={Layout}></AuthRoute>
            <Redirect path="/" to="/home" />
          </Switch>
        </div>
      </Suspense>
    </Router>
  );
}
